class environement = 
object (self) 
  val mutable currentImg = Sdlloader.load_image "./carte.bmp"
    val mutable nextImg = Sdlloader.load_image "./carte.bmp"
    val mutable filename = "" 
    val mutable grey = false
    val mutable grid = false
    val mutable prec = 10
method get_currentImg = currentImg

    method set_prec p =prec <- (10*p)
    method get_filename = filename

    method toggle_grey = function () -> grey <- not grey

    method toggle_grid = function () -> grid <- not grid

    method set_curImg i = function () -> match i with
      |[]->()
      |e::l -> filename <- e;
	currentImg <- Sdlloader.load_image e

          
    method analyse = function () ->
      MapTools.traitement currentImg nextImg;
      if (grey) then MapTools.image2grey nextImg nextImg;
      if (grid) then MapTools.quadrille nextImg nextImg (10*int_of_float(10.))
	
    method toto =function () -> print_string "toto"

end

let main = 
  ignore (GMain.Main.init ());
  Sdl.init [`VIDEO];
  let workspace = new  Environment.environment (new Interface.window1 ()) in
  (*ignore (window#imagechooser#connect#update_preview ~callback:window#setcurImg);
  ignore (window#button1#connect#clicked ~callback:window#analyse);
  ignore (window#button1#connect#clicked ~callback:(function () -> (window#drawImg (window#get_filename^".tmp"))));
  ignore (window#hscale1#connect#value_changed ~callback:(window#analyse window#hscale1#adjustment#value));
  ignore (window#togglebutton1#connect#clicked ~callback:window#toggle_grid);
  ignore (window#togglebutton1#connect#clicked ~callback:window#analyse window#hscale1#adjustment#value);
    ignore (window#togglebutton1#connect#clicked ~callback:(function () -> (MapTools.objMake window#get_currentImg 50 [])));
  ignore (window#togglebutton2#connect#clicked ~callback:window#toggle_grey);
  ignore (window#togglebutton2#connect#clicked ~callback:window#analyse window#hscale1#adjustment#value);
  window#button2#connect#clicked ~callback:(function () -> MapTools.savepixelcolor window#get_currentImg);*)
  workspace#init_gui

let _ = main;
